#!/usr/bin/env python

#################################################################################
#
# Copyright (c) 2006 Michigan State University
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#################################################################################

#################################################################################
#
#	Author:
#		Nathan Collins <npcollins@gmail.com>
#
#################################################################################

from oaivars import *
from datetime import datetime

# write to log files

def hErr(message,stamp = 1):
	logit(g['HE'],message, stamp)

def logDone(message,stamp = 1):
	logit(g['CMPLT'],message, stamp)

def logit(filename,message,stamp = 1):
	file = oailogfile(filename)
	file.log(message, stamp)
	file.close()

class oailogfile:
	def __init__(self,filename):
		self.filename = filename
		self.fh = open(self.filename,'a')

	def log(self,message,stamp):
		ts = ''
		if stamp:
			ts = str(datetime.now())[0:19] + ' | '
		self.fh.write(ts + message + '\n')
	
	def close(self):
		self.fh.close()

# eof

